# GF_PY312_CLASS_Markdown_3_BS4.py
# Create By GF 2025-04-01 13:30

import bs4
import markdown
# ..................................................
BeautifulSoup = bs4.BeautifulSoup

# ##################################################

class BS4_Markdown_3(object):

    def Markdown_Extract_Code_Block_from_String(Markdown_String:str) -> str:

        # Requirement: markdown 3.x / beautifulsoup4 4.x

        HTML_Content = markdown.markdown(Markdown_String)
        # ..........................................
        Soup = BeautifulSoup(HTML_Content, 'html.parser')
        HTML_Tag_Code = Soup.find("code")
        # ..........................................
        if (HTML_Tag_Code == None):
            return None
        # ..........................................
        else:
            Code_Block_String = HTML_Tag_Code.get_text()
            return Code_Block_String
